/**
 * @title HHLoginForm.java 
 * @description 	登陆表单文件
 * @create 			2012-7-18 下午08:51:20 By xjiujiu
 * @package 		apps.site.form
 * @copyright 		Copyright (c) 2011-2012 http://xyrj.hhtc.edu.cn.com. All right reserved
 * @version         $Id$
 * XYRJ-Java-Project
 */

package apps.admin.form;

import org.eclipse.jdt.internal.compiler.ast.ThrowStatement;

import com.xyrj.core.HHPojo;
import com.xyrj.core.IHHForm;
import com.xyrj.exception.HHValidateException;
import com.xyrj.image.HHVerificationCodeUtils;
import com.xyrj.mvc.HHView;
import com.xyrj.utils.HHVerify;

/**
 * 用户登陆表单
 * 
 * 验证用户输入是否符合要求 
 * @ClassName: HHLoginForm 
 * @Description:
 * @author maoyun0903(maoyun19900818@163.com);
 * @date 2012-10-8 下午8:52:55 
 * @version V1.0
 */
public class HHLoginForm implements IHHForm
{

	/* (非 Javadoc) 
	 * <p>验证用户登陆信息</p>
	 * 
	 * <p>description: 检测用户登陆信息是否满足相关的约束性要求</p> 
	 *
	 * @title validate 
	 * @param HHPojo pojo 模块的POJO对象
	 * @see com.xyrj.core.IHHForm#validate(com.xyrj.core.HHPojo) 
	 */
	@Override
	public void validate(HHPojo pojo) throws HHValidateException
	{
		if(true == HHVerify.isEmpty((String)pojo.getField("user_name"))) {
			throw new HHValidateException("用户名不能为空！");
		}
		if(true == HHVerify.isEmpty((String)pojo.getField("password"))) {
			throw new HHValidateException("用户密码不能为空！");
		}
	}

	/* (非 Javadoc) 
     * <p>非POJO表单提交验证</p>
     * 
     * <p>description: </p> 
     *
     * @title validate 
     * @param  HHView view 当前的视图对象
     * @throws HHValidateException 
     * @see com.xyrj.core.IHHForm#validate(com.xyrj.mvc.HHView) 
     */
    @Override
    public void validate(HHView view) throws HHValidateException
    {
	    //some code 
    }
    /**
     * 验证码是否一致
     * @Title: valicode 
     * @Description:  
     * @param @param requestAttr
     * @param @param sessionAttr  
     * @return void  
     * @throws
     */
	public void valicode(Object requestAttr, Object sessionAttr) throws HHValidateException{
		if(null==requestAttr||"".equals(requestAttr)){
			throw new HHValidateException("验证码不能为空~");
		}
		String validate = (String)requestAttr;
		String valicode = (String)sessionAttr;
		if(!valicode.equals(validate)){
			throw new HHValidateException("验证码输入错误~");
		}
		
	}

}
